<!doctype html>
<html lang="zh-hans" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>博客系统 | 列表</title>
    <link rel="stylesheet" href="/css/common.css">
    <link rel="stylesheet" href="/css/article.css">
    <link rel="stylesheet" href="/editor.md/css/editormd.min.css" />
</head>
<body>
<div class="nav">
    <!-- 头部导航 navigator -->
    <img src="/img/logo.png" alt="logo 图">
    <span class="title" th:text="${user.nickname} + '的博客'">雷世雄的博客</span>
    <!-- 无意义的，为了撑开布局空间 -->
    <span class="spacer"></span>
    <a href="/">主页</a>
    <a href="/edit.html">写博客</a>
    <!-- 注销：删除用户的登录状态，需要动态操作，暂时不管 -->
    <a href="/logout">注销</a>
</div>

<div class="container">
    <!-- 内容区 -->
    <div class="container-left">
        <!-- 个人信息 -->
        <div class="card">
            <img src="img/doge.jpg" alt="作者头像" class="avatar" th:src="${user.avatar}">
            <h3 th:text="${user.nickname}">雷世雄</h3>
            <a href="https://gitee.com/peixinchen2" target="_blank" th:href="${user.git}">我的 git</a>
            <div class="counter">
                <span>文章</span>
                <span>分类</span>
            </div>
            <div class="counter">
                <span th:text="${articleCount}">10</span>
                <span th:text="${typeCount}">2</span>
            </div>
        </div>
    </div>
    <div class="container-right">
        <div class="blog-content">
            <h3 th:text="${article.title}">关于如何学好 CSS</h3>
            <div class="date"  th:text="${article.publishedAt}">2021-12-22</div>
            <!-- 博客正文 -->
            <div id="content" th:text="${article.content}">
                从今天起我要好好敲代码.
                Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut recusandae omnis natus ut! Autem alias
                ullam sit facilis ipsa dolore, molestiae neque aperiam in a facere dolor mollitia dolorum animi.
                Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut recusandae omnis natus ut! Autem alias
                ullam sit facilis ipsa dolore, molestiae neque aperiam in a facere dolor mollitia dolorum animi.
                Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut recusandae omnis natus ut! Autem alias
                ullam sit facilis ipsa dolore, molestiae neque aperiam in a facere dolor mollitia dolorum animi.
            </div>
        </div>

        <!-- 引入 editor.md -->
        <script src="/js/jquery.min.js"></script>
        <script src="/editor.md/lib/marked.min.js"></script>
        <script src="/editor.md/lib/prettify.min.js"></script>
        <script src="/editor.md/editormd.js"></script>
        <script>
                // 找到 id=content 的标签
                // 从标签中读取出 markdown 内容
                var markdown = document.querySelector("#content").innerHTML;
                document.querySelector("#content").innerHTML = "";
                // 利用 editor.md 将 markdown 转成 html 格式，并且填充回 id=content 的标签
                editormd.markdownToHTML('content', { markdown: markdown });
            </script>
    </div>
</body>
</html>